#include<bits/stdc++.h>
#define int long long 
using namespace std;

inline int read() {
	int x = 0, f = 0; char ch = getchar();
	while(ch < '0' or ch > '9') f |= (ch == '-'), ch = getchar();
	while(ch >= '0' and ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
int __stk[128], __top;
inline void write(int x) {
    if(x < 0) putchar('-'), x = -x;
	do { __stk[++__top] = x % 10, x /= 10; } while(x);
	while (__top) putchar(__stk[__top--] + '0');
}
bool stmer;
const int N = 2e3 + 10, M = 2e5 + 10;
int n, m, q, ans, sx, sy, ex, ey;
int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
bool vis[N][N];
char s[N][N];
void dfs(int x, int y) {
    vis[x][y] = 1;
    for(int i = 0; i < 4; i++) {
        int tx = x + fx[i][0], ty = y + fx[i][1];
        if(tx >= sx and tx <= ex and ty >= sy and ty <= ey and s[tx][ty] == '1' and !vis[tx][ty]) dfs(tx, ty);
    }
}
bool edmer;
signed main() {
	freopen("unicom.in", "r", stdin);
	freopen("unicom.out", "w", stdout);
	cerr << "[Memory] " << (&stmer - &edmer) / 1024 / 1024 << " MB\n";
	n = read(), m = read(), q = read();
    for(int i = 0; i < n; i++) scanf("%s", s[i]);
    while(q--) {
        sx = read() - 1, sy = read() - 1, ex = read() - 1, ey = read() - 1, ans = 0;
        for(int i = sx; i <= ex; i++)
            for(int j = sy; j <= ey; j++) vis[i][j] = 0;
        for(int i = sx; i <= ex; i++)
            for(int j = sy; j <= ey; j++)
                if(s[i][j] == '1' and !vis[i][j]) ans++, dfs(i, j);
        write(ans), putchar('\n');
    }

    cerr << "[Runtime] " << (double) clock() / CLOCKS_PER_SEC << " seconds";
	return 0;
} 